﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.DependencyInjection;
using StyleMVVM.ViewModel;
using StyleMVVM.ViewModel.Impl;

namespace StyleMVVM.Utilities
{
	public sealed class GlobalCache : IGlobalCache
	{
		public static void RegisterExport(IDependencyInjectionContainer container)
		{
			container.Register(typeof(GlobalCache)).As(typeof(IGlobalCache)).AndShared();
		}

		public void AddWithAbsoluteExpireTime(string key, object value, DateTimeOffset absoluteExpire)
		{
			CacheManager.DefaultInstance.AddWithAbsoluteExpireTime(key, value, absoluteExpire);
		}

		public void AddWithSlidingExpireTime(string key, object value, TimeSpan absoluteExpire)
		{
			CacheManager.DefaultInstance.AddWithSlidingExpireTime(key, value, absoluteExpire);
		}

		public void RemoveFromCache(string key)
		{
			CacheManager.DefaultInstance.RemoveFromCache(key);
		}

		public object GetValue(string key)
		{
			return CacheManager.DefaultInstance.GetValue(key);
		}
	}
}